import { createStore, combineReducers } from "redux";
import { persistStore, persistReducer } from "redux-persist";
import storage from "redux-persist/lib/storage";
import { CollApsedReducer } from "./reducers/CollapsedReducer";
import { LoadingReducer } from "./reducers/LoadingReducer";
import { UserReducer } from "./reducers/UserReducer";

// 持久化配置
const persistConfig = {
  key: "react-admin",
  storage,
  whitelist: ["CollApsedReducer","UserReducer"],
};

const reducer = combineReducers({
  CollApsedReducer,
  LoadingReducer,
  UserReducer
});

const persistedReducer = persistReducer(persistConfig, reducer);

const store = createStore(persistedReducer);
const persistor = persistStore(store);

export { store, persistor };
